package petrochina.company.electric.ui.adapter;

import android.content.Context;
import android.graphics.Color;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;

import petrochina.company.electric.R;
import petrochina.company.electric.app.AppAdapter;
import petrochina.company.electric.model.FillUserResult;

/**
 * desc   : 状态数据列表
 */
public final class FillSearchAdapter extends AppAdapter<FillUserResult> {

    public FillSearchAdapter(Context context) {
        super(context);
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new ViewHolder();
    }

    private final class ViewHolder extends AppAdapter<?>.ViewHolder {

        private final TextView tvWorkPlace;
        private final TextView tvStation;
        private final TextView tvFillInputStatus;
        private final TextView tvUserName;

        private ViewHolder() {
            super(R.layout.fill_search_item);
            tvWorkPlace = findViewById(R.id.tv_work_place);
            tvStation = findViewById(R.id.tv_station);
            tvFillInputStatus = findViewById(R.id.tv_fill_input_status);
            tvUserName = findViewById(R.id.tv_user_name);
        }

        @Override
        public void onBindView(int position) {
            FillUserResult fillUserResult = getItem(position);
            tvWorkPlace.setText(fillUserResult.getWorkPlace());
            tvStation.setText(fillUserResult.getStation());
            tvUserName.setText(fillUserResult.getUserName());
            if (fillUserResult.getInputStatus() == 1) {
                //已输入
                tvFillInputStatus.setTextColor(Color.parseColor("#0D63D4"));
                tvFillInputStatus.setText("已输入");
            } else {
                //未输入
                tvFillInputStatus.setTextColor(Color.parseColor("#999999"));
                tvFillInputStatus.setText("未输入");
            }
        }
    }
}